﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace game
{
    class Program
    {
        static void Main(string[] args)
        {
            //增加
            /*Console.WriteLine("游戏名字");
            string nameGame = Console.ReadLine();
            Console.WriteLine("游戏价钱");
            int PriceGame = int.Parse(Console.ReadLine());
            Console.WriteLine("游戏库存");
            int stockGame = int.Parse(Console.ReadLine());
            string sql = string.Format("insert into game values('{0}','{1}','{2}')", nameGame, PriceGame, stockGame);
            bool result = opr_game1.GetNonQuery(sql);
            if (result)
            {
                Console.WriteLine("成功");
            }
            else
            {
                Console.WriteLine("失败");
            }
            Console.WriteLine("+----------------------------------------");*/
            //查询
            string sql2 = "select * from game";
            SqlDataReader dr = opr_game1.Select(sql2);
            Console.WriteLine("游戏名字\t游戏价钱\t游戏库存");
            while (dr.Read())
            {
                Console.WriteLine("{0}\t{1}\t\t{2}", dr[1], dr[2],dr[3]);
            }

            //统计查询
            string sql3 = "select sum(PriceGame*stockGame) as 总价格 from game";
            Console.WriteLine("游戏总金额：{0}元",opr_game1.ExecuuteScalar(sql3));
            /*SqlDataReader dr1 = opr_game1.Select(sql3);
            Console.WriteLine("+----------------------------------------");
            Console.Write("总价格：");
            while (dr1.Read())
            {
                Console.WriteLine(dr1[0]) ;
            }*/
        }
    }
}
